package com.nacrtstudio.webgiftshop.pages;

import java.util.Date;

import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;

import com.nacrtstudio.webgiftshop.facade.Controller;
import com.nacrtstudio.webgiftshop.model.shop.CartItem;
import com.nacrtstudio.webgiftshop.model.shop.Order;
import com.nacrtstudio.webgiftshop.model.shop.PackedGift;

public class PayingMethodDetails {
	@Inject
	private Request request;
	public void onActivate() {
		try {
			if (controller.getRequest()==null) {
	    		controller.setRequest(request);
			}
		} catch (Exception e) {
		}
	}
	
	@Inject
	private Controller controller;
	
	@Persist
	private Order order;
	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
	@Persist
	private String message;
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	@Property
	private PackedGift packedGift;
	
	public int getItemNumber(PackedGift packedGift){
		int result = 1;
		   for (PackedGift g : order.getPackedGifts()) {
		     if (g.equals(packedGift)) return result;
		     result++;
		   }
		   return 1;
	}

}
